package classwork.demo1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo1 {
    public static void main(String[] args) throws Exception {
        //Class.forName("com.mysql.jdbc.Driver");

        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "root", "root");

        Statement stat = con.createStatement();

        String sql ="SELECT * FROM dept";
        ResultSet rs = stat.executeQuery(sql);

        while (rs.next()){
            System.out.println(rs.getInt("deptno")+"\t"+rs.getString("dname")+
                    "\t"+rs.getString("loc"));
        }

        rs.close();
        stat.close();
        con.close();
    }
}
